import pojo.entity.Person;

import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;

public class GetClassConstructorInfo {
    public static void main(String[] args) {
        Constructor[] cons= Person.class.getDeclaredConstructors();
        System.out.println("------------------");
        for (Constructor constructor:cons){
            System.out.print("访问修饰符：");
            int modifier=constructor.getModifiers();
            if((modifier& Modifier.PUBLIC)==Modifier.PUBLIC){
                System.out.println("public");
            } else if ((modifier& Modifier.PROTECTED)==Modifier.PROTECTED) {
                System.out.println("protected");
            }else if((modifier& Modifier.PRIVATE)==Modifier.PRIVATE){
                System.out.println("private");
            }else {
                System.out.println("default(package)");
            }
            Class[] params=constructor.getParameterTypes();
            if(params.length==0){
                System.out.println("该构造方法没有参数");
            }else {
                System.out.print("该构造方法的参数列表为：[");
                for (int i = 0; i < params.length; i++) {
                    if(i!=0){
                        System.out.print(", ");
                    }
                    System.out.print(params[i].getName());
                }
                System.out.println("]");
            }
            System.out.println("------------------");
        }

    }
}
